#include "timer_domain.h"
#include "session_recycler.h"
#include <stdio.h>
#include <sys/time.h>
#include "common.h"

timer_domain::timer_domain() : prev(NULL), next(NULL), session_ptr(NULL) {
	retick();
}

timer_domain::~timer_domain(){
	LOGI("~timer_domain");
	session_recycler* rec = session_recycler::get_instance();
	rec->remove(*this);
	rec->print_list();
}

void timer_domain::retick(){
	tick = get_cur_tick();
}

long timer_domain::get_cur_tick()
{
   struct timeval tv;
   gettimeofday(&tv, NULL);
   return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}

bool timer_domain::expire(){
	return (get_cur_tick() - tick > RECYCLE_TIME);
}
